import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		new Main(args);
	}

	public Main(String[] args)
	{
		if(args.length != 1)
		{
			System.err.println("Usage `java Main FILE`");
			return;
		}

		// Initiate algorithms
		PathAlg dynamic1 = new NaiveDynamic();
		PathAlg dynamic2 = new MemoizingDynamic();
		PathAlg optimal = new ExhaustiveAlgorithm(); // MemoizingDynamic();
		
		// Set up graphs
		dynamic1.buildGraph(args[0]);
		dynamic2.buildGraph(args[0]);
		optimal.buildGraph(args[0]);

		// Run algorithms and print
		dynamic1.runAlgorithmTimed();
		//printAlgorithm(dynamic1);
		
		dynamic2.runAlgorithmTimed();
		printAlgorithm(dynamic2);
		
		optimal.runAlgorithmTimed();
		printAlgorithm(optimal);
	}

	private void printAlgorithm(PathAlg alg)
	{
		System.out.println("=== Running " + alg.getName() + " === ");
		System.out.print("Min. EL: "
			+ alg.getExpectedLatency() + "\nPath: ");
		for(int i : alg.getPath())
		{
			System.out.print((i+1) + " ");
		}

		System.out.println("\nExecution time in ms: " + alg.getTime());
		System.out.println();
	}
}

